Skip to content

temporal: Support use_existing option for start_workflow - #6

Merged
kstewartfigma merged 2 commits into
masterfrom
kstewart/ruby-start-use-existing
Nov 18, 2026
Merged

kstewartfigma merged 2 commits into
masterfrom
kstewart/ruby-start-use-existing

Conversation

@kstewartfigma

@kstewartfigma kstewartfigma commented Oct 9, 2026 •

Copy link
Copy Markdown

Written by AI

Description

An ordinary Temporal.start_workflow call with a workflow ID that is already running can opt into workflow_id_conflict_policy: :use_existing. The call returns that execution's actual run ID. It does not start another execution or deliver the second call's input. Without the option, duplicate starts continue to raise Temporal::WorkflowExecutionAlreadyStartedFailure.

Changes

  • Add the conflict-policy enum and request field to the pinned Temporal API bindings through a small, repeatable backport script wired into make proto.
  • Forward :use_existing and explicit :fail for ordinary starts. Keep the closed-run workflow_id_reuse_policy separate and reject its incompatible :terminate_if_running value when a conflict policy is specified.
  • Reject the option on signal-with-start, cron-style schedule_workflow, and Temporal::Testing.local!, where this path cannot honor it.
  • Document the opt-in behavior and add unit and server-contract integration coverage.

First-party SDK coverage parity

Pinned reference: temporalio/sdk-ruby at 2169e3e0dc2b4f59dbf9cc93205e19c2c01a037e.

First-party behavior Coverage here
Running USE_EXISTING returns the current run handle and original result examples/spec/integration/start_workflow_spec.rb: same run ID, original start input in history, and result after signaling the original workflow. client_spec.rb checks the returned server run ID.
Default running duplicate raises with the current run ID The same running integration case checks the default error. Existing grpc_spec.rb checks extraction of the duplicate run ID.
A completed run remains subject to failed-only reuse rejection The existing closed-run integration case now checks :allow_failed with :use_existing; another case checks :reject and :allow after termination.
Terminating a running workflow on conflict Outside this opt-in USE_EXISTING addition. The fork's existing :terminate_if_running reuse-policy test remains in place.

The first-party Ruby client sets the request field directly and uses the server response's run ID; this path does not delegate conflict handling to Core. Its Update-With-Start handler cases exercise a separate API.

November 17 merge validation

Merged master cc03140 (official-SDK protobuf coexistence) into this branch. The generation pipeline retains both the conflict-policy backport and coexistence guards; the backport also honors PROTO_OUT.

  • Coder Ruby 3.4.7: full suite 654 examples, 0 failures, 1 optional coexistence skip; with the coexistence Gemfile, 654 examples, 0 failures.
  • Official SDK loaded first: 111 client/gRPC examples pass.
  • make proto twice exactly reproduces the generated files; a separate output directory matches lib/gen and leaves checked-in files unchanged.
  • All six workflow-start integration examples pass on Temporal 1.29.1 / PostgreSQL.
  • CI now keeps the legacy 1.22 regression suite and runs the six workflow-start cases separately on 1.29.1. The old server rejects running USE_EXISTING; only that newly tagged case is excluded from the legacy run. The aggregate test_examples check requires both configurations to pass.
  • Independent Sol 6.1 / high merge review and targeted CI-matrix review: no actionable findings.

Local validation limitation: the legacy matrix ran 92 examples with two search-attribute failures. The same two fail from the already-green SDK #7 branch against that local server; they are not isolated to this merge. The subsequent clean hosted run passed the legacy and modern example jobs, their aggregate check, the unit suite, and the coexistence suite on 948c5c1. The earlier full modern-server run exposed unrelated search-attribute/namespace expectations, so those tests retain their existing legacy-server coverage.

Test Plan

Validated on October 19, 2026 against this PR's then-current head, 6140c92efc089265e2c71d29f241be2061063323, and base 8dd84b3bf3255b595cbabd93e128d9fe1121c50b, in an authenticated Coder devbox (Linux x86_64, Ruby 3.4.7):

  • Focused client, gRPC, and testing-override unit specs: 135 examples, 0 failures.
  • Live examples/spec/integration/start_workflow_spec.rb against Temporal Server 1.32.0 (CLI 1.9.1): 6 examples, 0 failures. Verified that a running duplicate with :use_existing returns the original actual run ID, retains the original start input, and produces the original workflow's signal result. Also verified default duplicate rejection, closed-run reuse policies, and existing :terminate_if_running behavior.
  • Full unit suite: 652 examples, 7 failures; the exact base had 645 examples, the same 7 failures. These are four ReplayTester assertions and three Ruby 3.4 stack-trace expectations; this PR introduces no additional failures in that comparison.
  • Bundled make proto ran twice successfully against pinned submodule ae312b0724003957b96fb966e3fe25a02abaade4. Both runs exactly reproduced the committed generated files, with no generated diff. This Linux validation resolves the earlier macOS tool-execution blocker.
  • git diff --check passed and the tracked checkout remained clean.

On November 2, the six ordinary-start integration cases passed again against Temporal Server 1.32.0 while validating the Update-With-Start follow-up (#8), stacked on this exact parent revision.

Rerun

With the repository's dependencies and pinned proto submodule installed:

bundle exec rspec spec/unit/lib/temporal/client_spec.rb spec/unit/lib/temporal/grpc_spec.rb spec/unit/lib/temporal/testing/temporal_override_spec.rb
make proto
make proto
git diff --exit-code -- lib/gen

For live validation, start a local Temporal dev server on port 17233 and run the example worker and specs from examples/ with TEMPORAL_HOST=127.0.0.1, TEMPORAL_PORT=17233, TEMPORAL_NAMESPACE=default, and TEMPORAL_TASK_QUEUE=sdk-validation-pr6:

bundle exec ruby bin/worker
# In a separate shell with the same environment:
bundle exec rspec spec/integration/start_workflow_spec.rb --format documentation

Limits

The October/November 2 results above were manual validation. The current November 17 revision also has automated unit, official-SDK coexistence, and legacy/conflict-policy integration checks in GitHub Actions, all passing. Live validation covered Server 1.32.0, not production deployment, mixed-version rollout, or every conflict policy. The seven baseline unit failures remain unresolved.

November 17 review follow-up

Clean Linux protobuf generation against current head 948c5c1 and the pinned proto submodule passed twice using grpc-tools 1.85.0 (protoc 35.1); both outputs exactly match lib/gen. The Bugbot regeneration report was not reproducible: Ruby String#scan with a String argument performs literal matching, and this compiler emits the expected escaped descriptor bytes. The thread is resolved without changing the generator.

The monorepo's ignore_already_started_failure wrapper still serves consumers on the older SDK and returns a skipped-run sentinel. Adopting USE_EXISTING changes that return contract to an actual run ID, so removal belongs with a separately validated caller migration after this SDK is adopted.

@kstewartfigma
kstewartfigma marked this pull request as ready for review October 30, 2026 23:00
@kstewartfigma kstewartfigma changed the title temporal: Support use-existing workflow starts temporal: Support use_existing option for start_workflow Oct 30, 2026
@kstewartfigma
kstewartfigma requested review from a team and kahlstrom-figma and removed request for a team October 30, 2026 23:01
@yfang-figma

Copy link
Copy Markdown

Nice. I think we can remove the ignore_already_started_failure start_workflow options now?

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 948c5c1. Configure here.

@kstewartfigma
kstewartfigma merged commit e810243 into master Nov 18, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants